<?php

namespace App\Admin\Actions\Grid\RowActions;

use App\Admin\Forms\AgreementAuditForm;
use App\Admin\Forms\DisPatchForm;
use App\Models\ProjectAgreement;
use Dcat\Admin\Form;
use Dcat\Admin\Widgets\Modal;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;

class AgreementStopAction extends RowAction
{
    protected $title = '<i class="feather icon-x-circle text-custom"></i> <span class="text-custom" title="">中止</span> &emsp;';

    public function confirm()
    {
        return '该协议【中止】后，协议将无法进行操作，且永久作废，确定要中止吗？';
    }

    public function handle(Request $request)
    {
        $id = $this->getKey();
        $agreementModel = ProjectAgreement::where('id', $id)->first();
        if (empty($agreementModel)) {
            $this->response()->error('参数有误');
        }
        $agreementModel->status = -2;
        $agreementModel->save();
        return $this->response()->success('操作成功')->refresh();
    }
}
